package com.yc.drawing;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

/**
 * Created by yc on 2016/1/5.
 */
public class MainActivity extends Activity{
    private ImageView img1;
    private ImageView img2;
    private Button btn_tongzhi;
    private Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        InitView();

//        findViewById(R.id.btn_ra).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                v.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.ra));
//            }
//        });
//1213
//        findViewById(R.id.btn_ras).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                v.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.ras));
//            }
//        });

        findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(img2.getVisibility() == View.INVISIBLE){
                    ShowImg2();
                    img1.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.turn));
                    img2.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.turns));
                }else if(img1.getVisibility() == View.INVISIBLE){
                    ShowImg1();
                    img2.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.turn));
                    img1.startAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.turns));
                }
            }
        });
       btn_tongzhi = (Button)findViewById(R.id.btn_tongzhi);
        btn_tongzhi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,TZActivity.class);
                startActivity(intent);
            }
        });


    }
    private void InitView(){
        img1 = (ImageView)findViewById(R.id.iv_first);
        img2 = (ImageView)findViewById(R.id.iv_second);
        ShowImg1();
    }

    private void ShowImg1(){
        img1.setVisibility(View.VISIBLE);
        img2.setVisibility(View.INVISIBLE);

    }
    private void ShowImg2(){
        img2.setVisibility(View.VISIBLE);
        img1.setVisibility(View.INVISIBLE);
    }
}
